import { CopyInfoPanelBase } from "../../CopyInfoPanelBase";
import { GTextFiled } from "../../../../../../com/mui/controls/GTextFiled";
import { GTextFormat } from "../../../../../common/GTextFormat";
import { FontUtil } from "../../../../../common/font/FontUtil";
import { FilterConst } from "../../../../../component/gconst/FilterConst";
import { SecTimerView } from "../../../common/SecTimerView";
import { GlobalStyle } from "../../../../../common/global/GlobalStyle";
import { EventName } from "../../../../mvc/EventName";
import { ObjCreate } from "../../../common/ObjCreate";
import { Language } from "../../../../../../extend/language/Language";
import { HTMLUtil } from "../../../../../../com/gengine/utils/HTMLUtil";
import { CopyConfig } from "../../../../resource/CopyConfig";
import { SGuildRobCityOneCopyInfo } from "../../../../../../Message/Public/SGuildRobCityOneCopyInfo";
import { RemainTimeTool } from "../../../award/RemainTimeTool";
import { DataEvent } from "../../../../events/DataEvent";
import { TBoss } from "../../../../../../Message/Db/Tables/TBoss";
import { BossConfig } from "../../../../resource/BossConfig";
import { _millSeconds } from "../../../../../../this/_millSeconds";
import { Vector } from "../../../../../../__AS3__/vec/Vector";
type int = number;
//class GuildRobCityCopyOneInfoPanel
    
    export  class GuildRobCityCopyOneInfoPanel extends CopyInfoPanelBase
    {
        constructor(arg1: string="MagicTowerInfoButtonBg")
        {
            super(arg1);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._secTimer = new GTextFiled();
            this._secTimer.width = 240;
            this._secTimer.x = 10;
            this._secTimer.y = 10;
            this._secTimer.selectable = false;
            this._secTimer.defaultTextFormat = new GTextFormat(FontUtil.songtiName, 12, 16776960, true);
            this._secTimer.filters = [FilterConst.glowFilter];
            _bodySp.addChild(this._secTimer);
            this._secTimer2 = new SecTimerView();
            this._secTimer2.width = 240;
            this._secTimer2.x = 10;
            this._secTimer2.y = 35;
            this._secTimer2.selectable = false;
            this._secTimer2.defaultTextFormat = new GTextFormat(FontUtil.songtiName, 12, GlobalStyle.color5Uint, true);
            this._secTimer2.addEventListener(EventName.SecViewTimeChange, this.onSecTimerChange);
            this._secTimer2.filters = [FilterConst.glowFilter];
            _bodySp.addChild(this._secTimer2);
            ObjCreate.createGTextField(Language.getString(60924), 10, 60, 240, 20, _bodySp, GlobalStyle.textFormat6);
            this._descText = ObjCreate.createGTextField("", 10, 80, 240, 20, _bodySp, new GTextFormat(null, null, null, null, null, null, null, null, null, null, null, null, 3));
            this._descText.mouseEnabled = false;
            this._descText.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._descText.wordWrap = true;
            this._descText.mouseWheelEnabled = false;
            this._descText2 = ObjCreate.createGTextField("", 10, 80, 240, 20, _bodySp, new GTextFormat(null, null, null, null, null, null, null, null, null, null, null, null, 3));
            this._descText2.mouseEnabled = false;
            this._descText2.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._descText2.wordWrap = true;
            this._descText2.multiline = true;
            this._descText2.mouseWheelEnabled = false;
            this._descText2.htmlText = HTMLUtil.addColor(CopyConfig.instance.getRobCopyDesc(6), GlobalStyle.color5);
            this.resize();
            return;
        }

        public /* override */ updateInfos(arg1): void
        {
            var loc2=null;
            var loc3=false;
            var loc4=0;
            var loc1=arg1 as SGuildRobCityOneCopyInfo;
            if (loc1) 
            {
                this._millSeconds = loc1.millSeconds;
                if (loc1.millSeconds < 0) 
                {
                    this._secTimer2.setParse(HTMLUtil.addColor(Language.getString(60922), GlobalStyle.color5));
                    this._secTimer2.setLeftTime(Math.abs(loc1.millSeconds) / 1000);
                }
                else 
                {
                    this._secTimer2.setParse(HTMLUtil.addColor(Language.getString(60923), GlobalStyle.color5));
                    this._secTimer2.setLeftTime((this._totalTime - loc1.millSeconds) / 1000);
                }
                if (!this._bossVec) 
                {
                    this.initBossVec(loc1.bossInfo);
                }
                loc2 = "";
                loc3 = true;
                loc4 = 0;
                while (loc4 < this._bossVec.length) 
                {
                    loc2 = loc2 + ("\t" + Language.getStringByParam(60422, "  " + this._bossVec[loc4].name) + "\t（" + loc1.bossInfo[this._bossVec[loc4].code] + "/1） \n");
                    if (loc1.bossInfo[this._bossVec[loc4].code] == 0) 
                    {
                        loc3 = false;
                    }
                    ++loc4;
                }
                this._descText.htmlText = HTMLUtil.addColor(loc2, GlobalStyle.color1);
                if (loc3) 
                {
                    this._secTimer2.stop();
                    this._secTimer.htmlText = Language.getString(60410) + HTMLUtil.addColor(RemainTimeTool.getRemainTimeBySeconds(loc1.millSeconds / 1000), GlobalStyle.color9);
                }
            }
            this.resize();
            return;
        }

        /* internal  */onSecTimerChange(arg1: DataEvent): void
        {
            this._millSeconds = this._millSeconds + 1000;
            var loc1=this._millSeconds < 0 ? 0 : _millSeconds / 1000;
            this._secTimer.htmlText = Language.getString(60410) + HTMLUtil.addColor(RemainTimeTool.getRemainTimeBySeconds(loc1), GlobalStyle.color9);
            return;
        }

        /* internal  */initBossVec(arg1: Map<any, any> /* flash.utils.Dictionary */): void
        {
            var loc1=null;
            var loc2=null;
            this._bossVec = new Vector.<TBoss>();
            var loc3=0;
            var loc4=arg1;
            for (loc2 in loc4) 
            {
                loc1 = BossConfig.instance.getInfoByName(parseInt(loc2));
                if (!loc1) 
                {
                    continue;
                }
                this._bossVec.push(loc1);
            }
            return;
        }

        /* internal  */resize(): void
        {
            this._descText2.y = this._descText.y + this._descText.textHeight + 8;
            _bg.height = this._descText2.y + this._descText2.textHeight + 10;
            return;
        }

        public clean(): void
        {
            this._secTimer2.dispose(false);
            return;
        }

        /* internal */ /* var */_totalTime: int=1800000;

        /* internal */ /* var */_secTimer: GTextFiled;

        /* internal */ /* var */_secTimer2: SecTimerView;

        /* internal */ /* var */_descText: GTextFiled;

        /* internal */ /* var */_descText2: GTextFiled;

        /* internal */ /* var */_millSeconds: int;

        /* internal */ /* var */_bossVec: Vector.<TBoss>;
    }
